/**
 * 列表初始化
 */
var RankingPar = {
    id: "RankingTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
RankingPar.initColumn = function () {
    return [
        {title:'选择项',field: 'selectItem', radio: true},
        {title: '分销姓名', field: 'userId', visible: true, align: 'center', valign: 'middle'},
        {title: '已推广总人数', field: 'orderNo', visible: true, align: 'center', valign: 'middle'},
        {title: '未推广总人数', field: 'orderType', visible: true, align: 'center', valign: 'middle'},
    ];
};
/**
 * 检查是否选中
 */
RankingPar.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        RankingPar.seItem = selected[0];
        return true;
    }
};

/**
 * 查询列表
 */
RankingPar.search = function () {
    //带参查询
    RankingPar.table.refresh({query: RankingPar.formParams()});
};

//表单参数
RankingPar.formParams = function() {
    var queryData = {};
    queryData['id'] = $("#id").val();
    queryData['userId'] = $("#userId").val();
    queryData['beginTime'] = $("#beginTime").val();
    queryData['endTime'] = $("#endTime").val();
    return queryData;
}

//在整个页面加载的时候
$(function () {
    //获取列表数据
    var defaultColunms = RankingPar.initColumn();
    var table = new BSTable(RankingPar.id, "/ranklist/list", defaultColunms);
    table.setPaginationType("server");
    table.setQueryParams(RankingPar.formParams());
    RankingPar.table = table.init();
});
